var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var voteHelper = require("helper/vote");
var openHelper = require("helper/open");
var alayoutImg=ui("alayoutImg");
var root = ui("$");
var checkBox = ui("checkBox");
var labelRemark=ui("labelRemark");
var aLayoutCheck=ui("aLayoutCheck");
var imgCheckBox = ui("imgCheckBox");
var iconCheck = ["source://image/common/checkbox.png","source://image/common/checkboxcheck.png"];
root.setMapping({
	"aLayoutCheck.tag":"multiMaxNum",
	"labelRemark.tag":"id",
	"alayoutImg.visible":"isShowImg",
	"alayoutImg.tag":"bigPathImg",
	"labelRemark.text" : "remark",
	"imageView.source" : "pathImg",
	"imageViewCheck.source" : "source"
});
//图片浏览注册事件
alayoutImg.on("touch", function(data) {
	var jsonImgs=[];
	jsonImgs.push({source:alayoutImg.tag});
	openHelper.open("source://view/reuse/imgBrowser.ui", {
		imgDatas :JSON.stringify(jsonImgs),index:0
	});
})
var checkboxFlag=false;
checkBox.on("checkChanged", function(b) {
	var d = {};
	if(b){//true
		voteHelper.multiCheck(parseInt(voteHelper.multiCheck())+1);
		if(parseInt(voteHelper.multiCheck())>parseInt(aLayoutCheck.tag)){//大于最大
			nf.toast("超过最大可选项!");
			voteHelper.multiCheck(parseInt(voteHelper.multiCheck())-1);
			return;
		}
		checkboxFlag=true;
	}else{
		if(checkboxFlag){
			voteHelper.multiCheck(parseInt(voteHelper.multiCheck())-1);
			checkboxFlag=false;
		};
	}
	b ? imgCheckBox.source=iconCheck[1] : imgCheckBox.source=iconCheck[0];
	d.checked = b;
	d.id = labelRemark.tag;
	do_Page.fire("check_change_event", d);
})